#pragma once

#include <glm/glm.hpp>
#include <array>

#include "Utilies.h"

namespace vkengine
{

	class Device;
	class Pipeline;
	class Texture;
	class VertexBuffers
	{
	public:
		void CreateBuffer(Device* device, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory);
		void CreateVertexBuffer(Device* device, VkCommandPool commandPool);
		void CreateIndexBuffer(Device* device, VkCommandPool commandPool);

		void CreateUniformBuffers(Device* device);
		void UpdateUniformBuffer(Device* device, uint32_t currentImage);

		void CreateDescriptorPool(Device* device);
		void CreateDescriptorSets(Device* device, Pipeline* pipeline, Texture* texture);

		void Cleanup(VkDevice device);

		VkBuffer GetVertexBuffer(){ return m_VertexBuffer; }
		VkBuffer GetIndexBuffer() { return m_IndexBuffer; }

		std::vector<VkDescriptorSet> GetDescriptorSets() { return m_DescriptorSets; }
		VkCommandBuffer BeginSingleTimeCommands(Device* device, VkCommandPool commandPool);
		void EndSingleTimeCommands(Device* device, VkCommandBuffer commandBuffer, VkCommandPool commandPool);
		void CopyBuffer(Device* device, VkCommandPool commandPool, VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size);
		uint32_t FindMemoryType(VkPhysicalDevice physicalDevice, uint32_t typeFilter, VkMemoryPropertyFlags properties);

	private:
		VkBuffer m_VertexBuffer{};
		VkDeviceMemory m_VertexBufferMemory{};
		VkBuffer m_IndexBuffer{};
		VkDeviceMemory m_IndexBufferMemory{};

		std::vector<VkBuffer> m_UniformBuffers;
		std::vector<VkDeviceMemory> m_UniformBuffersMemory;
		std::vector<void*> m_UniformBuffersMapped;

		VkDescriptorPool m_DescriptorPool{};
		std::vector<VkDescriptorSet> m_DescriptorSets;
	};
}